package cn.com.pc.content.domain.view;

import cn.com.pc.content.domain.Biz;
import cn.com.pc.content.domain.content.ContentType;
import cn.com.pc.content.domain.Site;
import cn.com.pc.content.jpa.BizConverter;
import cn.com.pc.content.jpa.ContentTypeConverter;
import cn.com.pc.content.jpa.SiteConverter;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Data;
import lombok.ToString;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;

import javax.persistence.*;
import java.time.LocalDateTime;

/**
 * 视图转换方法映射表
 */
@Entity
@DynamicInsert
@DynamicUpdate
@Table(name = "content_view_property")
@Data
@ToString
public class ContentViewProperty {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id")
    private Long id;

    @Column(name = "view_type")
    private String viewType;

    @Column(name = "site")
    @Convert(converter = SiteConverter.class)
    private Site site;

    @Column(name = "biz")
    @Convert(converter = BizConverter.class)
    private Biz biz;

    @Column(name = "content_type")
    @Convert(converter = ContentTypeConverter.class)
    private ContentType contentType;

    //转换方法类的bean名称 即@Service(converter)
    @Column(name = "converter")
    private String converter;

    @JsonIgnore
    @Column(name = "deleted")
    private boolean deleted;

    @Column(name = "created_at")
    private LocalDateTime createdAt;

    @Column(name = "created_by")
    private String createdBy;

}
